# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# NOTE: This file is auto generated by the elixir code generator program.
# Do not edit this file manually.

defmodule GoogleApi.ChromeUXReport.V1.Model.HistoryRecord do
  @moduledoc """
  HistoryRecord is a timeseries of Chrome UX Report data. It contains user experience statistics for a single url pattern and a set of dimensions.

  ## Attributes

  *   `collectionPeriods` (*type:* `list(GoogleApi.ChromeUXReport.V1.Model.CollectionPeriod.t)`, *default:* `nil`) - The collection periods indicate when each of the data points reflected in the time series data in metrics was collected. Note that all the time series share the same collection periods, and it is enforced in the CrUX pipeline that every time series has the same number of data points.
  *   `key` (*type:* `GoogleApi.ChromeUXReport.V1.Model.HistoryKey.t`, *default:* `nil`) - Key defines all of the unique querying parameters needed to look up a user experience history record.
  *   `metrics` (*type:* `%{optional(String.t) => GoogleApi.ChromeUXReport.V1.Model.MetricTimeseries.t}`, *default:* `nil`) - Metrics is the map of user experience time series data available for the record defined in the key field. Metrics are keyed on the metric name. Allowed key values: ["first_contentful_paint", "first_input_delay", "largest_contentful_paint", "cumulative_layout_shift", "experimental_time_to_first_byte", "experimental_interaction_to_next_paint"]
  """

  use GoogleApi.Gax.ModelBase

  @type t :: %__MODULE__{
          :collectionPeriods =>
            list(GoogleApi.ChromeUXReport.V1.Model.CollectionPeriod.t()) | nil,
          :key => GoogleApi.ChromeUXReport.V1.Model.HistoryKey.t() | nil,
          :metrics =>
            %{optional(String.t()) => GoogleApi.ChromeUXReport.V1.Model.MetricTimeseries.t()}
            | nil
        }

  field(:collectionPeriods, as: GoogleApi.ChromeUXReport.V1.Model.CollectionPeriod, type: :list)
  field(:key, as: GoogleApi.ChromeUXReport.V1.Model.HistoryKey)
  field(:metrics, as: GoogleApi.ChromeUXReport.V1.Model.MetricTimeseries, type: :map)
end

defimpl Poison.Decoder, for: GoogleApi.ChromeUXReport.V1.Model.HistoryRecord do
  def decode(value, options) do
    GoogleApi.ChromeUXReport.V1.Model.HistoryRecord.decode(value, options)
  end
end

defimpl Poison.Encoder, for: GoogleApi.ChromeUXReport.V1.Model.HistoryRecord do
  def encode(value, options) do
    GoogleApi.Gax.ModelBase.encode(value, options)
  end
end
